<? $this -> load -> view('header');?>
<script type="text/javascript" src="<? echo base_url();?>script/jscolor.js"></script>
<script language="JavaScript">
	$(document).ready(function() {
		$("#addcontent").hide();
		getData();

	
	});
	function edit(id){
		$("#addcontent").toggle();
		$('#land_document_type_id').val("0");
		$('#land_document_type_name').val("");
		if(id!=0){
			
			$.getJSON("<?=$current_module?>/getdocumenttypebyid/"+id,function(data){
				$('#land_document_type_name').val(data.land_document_type_name);
				$('#land_document_type_id').val(data.land_document_type_id);
			});
		}
	}
	function save(){
		$("#addcontent").toggle();
		$.post("<?=$current_module?>/add_documenttype", { land_document_type_id: $('#land_document_type_id').val(),land_document_type_name:$('#land_document_type_name').val()},
		function(data) {
			alert(data);
			getData();
		});
	}
	
	
	function getData(){
		$('#datacontent').html("");
		$.get("<?=$current_module ?>/getdocumenttype", function(data){
			$('#datacontent').html(data);
		});
	}
		
</script>
<div id="middle">
	<? $this -> load -> view('land/left_menu');?>
	<div id="center-column">
		<div class="top-bar">
			<a   id="add_button"  href="javascript:edit(0);" class="button">Add </a>
			<h1>ประเภทที่ดินตามรูปแบบ</h1>
			<div class="breadcrumbs">
				<a href="#">Homepage</a> / <a href="#">Contents</a>
			</div>
		</div>
	
		<div id="addcontent" class="table">
			<table class="listing form" cellpadding="0" cellspacing="0">
				<tr>
					<th class="full" colspan="2">Add/Edit</th>
				</tr>
				<tr>
					<td style="width: 200px;">ประเภทที่ดิน</td>
					<td>
						<input type="text" id="land_document_type_name" style="width: 100%;" /> 
						<input type="hidden" id="land_document_type_id" value="0" />
					</td>
					
				</tr>
				<tr >
					<td>Description:</td>
					<td><textarea id="description" cols="50" rows="4"></textarea></td>
				</tr>
				<tr>
						<td>เลือกสีที่แสดงในแผนที่:</td>
						<td><input id="color_map" class="color"></td>
				</tr>
				<tr>
					<td colspan="2"><input type="button" value="Save" onclick="save()" /><input type="button" value="Back" onclick="edit(0)"/></td>
				</tr>
			</table>
		</div>
		
		<div class="table" id="datacontent">
         
		</div>
	</div>
	<div id="right-column">
		<strong class="h">Quick Info</strong>
		<div class="box">
			This is your admin home page. It will give you access to all things within the back end system that you will need to facilitate a smooth operation.
		</div>
	</div>
</div>
<? $this -> load -> view('footer');?>